package com.guojiaming.shop.controller;

import com.guojiaming.shop.bean.ResponseBody;
import com.guojiaming.shop.bean.ResponseFactory;
import com.guojiaming.shop.service.DatabaseService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author vivo
 */
@RestController
@RequestMapping("database")
public class DatabaseController {
    @Resource
    private DatabaseService databaseService;

    @GetMapping("init")
    public ResponseBody<Boolean> init() throws Exception {
        boolean result = databaseService.init();
        return ResponseFactory.success(result, result ? "数据库初始化成功" : "所有表都已经存在");
    }

    @GetMapping("update")
    public ResponseBody<String> update() {
        return ResponseFactory.success("预留接口", "数据库初始化成功");
    }
}
